import java.io.IOException;
import java.net.MalformedURLException;

import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.HtmlForm;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.html.HtmlSubmitInput;
import com.gargoylesoftware.htmlunit.html.HtmlTextInput;

public class robo {

	public static void main(String[] args) throws FailingHttpStatusCodeException, MalformedURLException, IOException, InterruptedException {

		// final WebClient client = new WebClient();
		// HtmlPage page =
		// client.getPage("file:///C:/Users/HP/Desktop/simplehtml.html");
		// HtmlElement div = page.getElementById("div1");
		// System.out.println(div.asText());
		// for (HtmlForm htmlForm : page.getForms()) {
		// HtmlInput inputUser = htmlForm.getInputByName("user");
		// inputUser.setAttribute("text", "tiago2");
		// System.out.println(inputUser.getAttribute("text"));
		// System.err.println(inputUser.getAttribute("text"));
		// }

		WebClient wb = new WebClient();
		HtmlPage p = (HtmlPage) wb.getPage("file:///C:/Users/HP/Desktop/simplehtml.html");
		HtmlForm f = p.getFormByName("input");
		HtmlTextInput text = (HtmlTextInput) f.getInputByName("user");
		HtmlSubmitInput btn = (HtmlSubmitInput) f.getInputByName("btn");
		text.setValueAttribute("Ziplok Java");
		System.out.println(p.asText());

		HtmlPage resultPage = (HtmlPage) btn.click();
		System.out.println(resultPage.asText());
	}
}
